package com.ruochen.recipe.customer;

import android.graphics.Rect;
import android.view.View;

import androidx.recyclerview.widget.RecyclerView;

public abstract class SpacesItemDecoration extends RecyclerView.ItemDecoration {

    @Override
    public final void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
        // Add top margin only for the first item to avoid double space between items
        int position = parent.getChildPosition(view);
        int itemCount = parent.getAdapter() != null ? parent.getAdapter().getItemCount() : -1;
        outRect.left = getSpaceLeft(position, itemCount);
        outRect.right = getSpaceRight(position, itemCount);
        outRect.top = getSpaceTop(position, itemCount);
        outRect.bottom = getSpaceBottom(position, itemCount);
    }

    public int getSpaceLeft(int position, int itemCount) {
        return 0;
    }

    public int getSpaceRight(int position, int itemCount) {
        return 0;
    }

    public int getSpaceTop(int position, int itemCount) {
        return 0;
    }

    public int getSpaceBottom(int position, int itemCount) {
        return 0;
    }
}
